/*
 * LocationHandler.hpp
 *
 *  Created on: Jan 29, 2015
 *      Author: wasp
 */

#ifndef DE_HEIMWEGHELDEN_LOCATIONHANDLER_HPP_
#define DE_HEIMWEGHELDEN_LOCATIONHANDLER_HPP_

#include <QtCore/QObject>
#include <bb/system/SystemDialog>
#include <bb/system/SystemUiResult>

class ApplicationUI;
class QNetworkReply;
class QNetworkAccessManager;
namespace bb
{
    namespace cascades
    {
        namespace maps
        {
            class MapView;
        }
        namespace places {
            class SelectedPlace;
        }
    }
    namespace platform
    {
        namespace geo
        {
            class GeoLocation;
        }
    }
}

namespace de
{
    namespace heimweghelden
    {
        namespace location {
            class Location;
        }
        namespace tracking {
            class Tracker;
        }

        class LocationHandler : public QObject
        {
            Q_OBJECT
        public:
            LocationHandler(QObject* parent = NULL);
            virtual ~LocationHandler();
            bool setMap(bb::cascades::maps::MapView* map);
            bb::cascades::maps::MapView* getMap();
            Q_INVOKABLE void updateDeviceLocation(double lat, double lon);
            Q_INVOKABLE void updateDestinationLocation(double lat, double lon, QString destcription);
            Q_INVOKABLE void resetDestinationLocation();
            Q_INVOKABLE void onResetRoute();
            Q_INVOKABLE void onRouteStart();
            Q_INVOKABLE void onRouteSetDuration(int duration);
            Q_INVOKABLE int onRouteUpdateHelden(QString number, bool active);
            public slots:
                //void onNetworkRequestFinished(QNetworkReply* reply);
                void onLapsedTimeChanged(int estimatedDuration);
                void gmapRouteRequestFinished();
                void onRouteStarted();
        private:
            ApplicationUI* app;
            int estimatedDuration;
            QNetworkReply* reply;
            bb::cascades::maps::MapView* mapView;
            de::heimweghelden::location::Location* location;
            de::heimweghelden::tracking::Tracker* tracker;
            bb::system::SystemDialog* dialog;
        };

    } /* namespace heimweghelden */
} /* namespace de */

#endif /* DE_HEIMWEGHELDEN_LOCATIONHANDLER_HPP_ */
